﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace dzs.Web.Outstorage
{
    public partial class ListYCK : Web.Admin.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["login"] != null)
                {
                    DataSet ds = Session["login"] as DataSet;

                    int roles_id = Convert.ToInt32(ds.Tables[0].Rows[0]["roles_id"].ToString());
                    int user_id = Convert.ToInt32(ds.Tables[0].Rows[0]["user_id"].ToString());

                    if (roles_id == 2)//仓管员
                    {
                        Bind();
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('您不是仓库管理员！');</script>");
                    }
                }
                else
                {
                    Maticsoft.Common.MessageBox.Show(this, "由于长时间未操作，登录信息已过期，请重新登陆!");
                }

            }

        }

        private void Bind()
        {
            dzs.BLL.out_storageList o = new BLL.out_storageList();

            DataSet ds = o.GetCheckUser(" status = 0 and alreadyCount = 0 ");

            this.GridView1.DataSource = ds;
            this.GridView1.DataBind();
        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "check")
            {
                if (e.CommandArgument != null)
                {
                    Session.Remove("out_proid");//去除以前的记录

                    string proid = e.CommandArgument.ToString();

                    GridViewRow drv = ((GridViewRow)(((LinkButton)(e.CommandSource)).Parent.Parent));
                    Label lbl_check_user_id = drv.FindControl("lbl_check_user_id") as Label;

                    Session["out_proid"] = proid;
                    Session["check_user_id"] = lbl_check_user_id.Text;

                    Response.Redirect("ListOutStorageDetail.aspx");
                    //ClientScript.RegisterStartupScript(this.GetType(), "", "<script>OpenPop('FramePopCheckStorageList.aspx','900px','390px');</script>");
                }
            }
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.GridView1.PageIndex = e.NewPageIndex;

            if (Session["login"] != null)
            {
                DataSet ds = Session["login"] as DataSet;

                int roles_id = Convert.ToInt32(ds.Tables[0].Rows[0]["roles_id"].ToString());
                int user_id = Convert.ToInt32(ds.Tables[0].Rows[0]["user_id"].ToString());

                if (roles_id == 2)//仓管员
                {
                    Bind();
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('您不是仓库管理员！');</script>");
                }
            }
            else
            {
                Maticsoft.Common.MessageBox.Show(this, "由于长时间未操作，登录信息已过期，请重新登陆!");
            }


        }
    }
}